# Maintainer: Antoni Aloy <aaloytorrens@gmail.com>
pkgname=liblxqt
pkgver=1.1.0
pkgrel=0
pkgdesc="Common base library for LXQt components"
url="https://github.com/lxqt/liblxqt"
# armhf blocked by extra-cmake-modules -> kwindowsystem
arch="all !armhf"
license="LGPL-2.0-or-later"
makedepends="
	cmake
	samurai
	lxqt-build-tools
	qt5-qttools-dev
	libqtxdg-dev
	kwindowsystem-dev
	qt5-qtx11extras-dev
	libxscrnsaver-dev
	"
subpackages="$pkgname-dev $pkgname-lang"
source="https://github.com/lxqt/liblxqt/releases/download/$pkgver/liblxqt-$pkgver.tar.xz"
options="!check" # No testsuite

# Enable backlight support when possible
case "$CARCH" in
	s390x|riscv64) ;;
	*) makedepends="$makedepends polkit-qt-1-dev" ;;
esac

build() {
	# Requires polkit-qt-1-dev which requires polkit
	# which is not available on rust-less arches like
	# s390x
	case "$CARCH" in
		s390x|riscv64)	_build_backlight=OFF ;;
		*)	_build_backlight=ON ;;
	esac

	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DBUILD_BACKLIGHT_LINUX_BACKEND=$_build_backlight \
		$CMAKE_CROSSOPTS
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

lang() {
	install_if="lang $pkgname=$pkgver-r$pkgrel"
	amove usr/share/lxqt/translations/$pkgname
}

sha512sums="
6789bc64da94d0643dfa7d234a95c533ff31123e9c7e52544d0951b309ce0e86c7323808c527f37b9dc7d06ebb35bef57a7713596d5969d2ae30ccb44cbec283  liblxqt-1.1.0.tar.xz
"
